const path = require('path');
const HtmlWebpackPlugin = require('html-webpack-plugin');  //在根目录内存生成一个入口html
const VueLoaderPlugin = require('vue-loader/lib/plugin');   //配置vue组件的加载器

const htmlPlugin = new HtmlWebpackPlugin({
  template: './src/index.html',   // 入口文件
  filename: 'index.html'   // 生成根目录内存下的入口文件
})

module.exports = {
  mode: "development",
  entry: path.join(__dirname, './src/index.js'),
  output: {
    path: path.resolve(__dirname, './dist'),
    filename: 'bundle.js'
  },
  plugins: [htmlPlugin,new VueLoaderPlugin()],
  module: {
    rules: [
      {test:/\.css$/, use:['style-loader','css-loader','postcss-loader']},
      {test:/\.less$/, use:['style-loader','css-loader','less-loader']},
      {test:/\.scss$/, use:['style-loader','css-loader','sass-loader']},
      {test:/\.jpg|png|gif|bmp|ttf|eot|svg|woff|woff2$/i, use:'url-loader?limit=61418 '},
      {test:/\.js$/, use:'babel-loader', exclude:/node_modules/},
      {test:/\.vue$/,use:'vue-loader'}
    ]
  }
}
